package br.com.cadele.beans;

import java.io.Serializable;
import java.util.ArrayList;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import br.com.cadele.model.Curso;
import br.com.cadele.service.CursoService;

import com.ocpsoft.pretty.faces.annotation.URLBeanName;
import com.ocpsoft.pretty.faces.annotation.URLMapping;

@ManagedBean(name="visualizarCursoBean")
@ViewScoped
@URLBeanName(value="visualizarCursoBean")
@URLMapping(id="visualizarCursoBean", pattern="/curso/visualizar", viewId="/pages/curso/visualizar.xhtml")
public class VisualizarCursoBean implements Serializable{

	private static final long serialVersionUID = 246516060000143374L;
	Curso curso;
    private CursoService cursoService;
    private ArrayList<Curso> cursoList;

    @PostConstruct
    public void init(){
    	cursoService = new CursoService();
        cursoList = cursoService.getAll();
    }
    
    public void salvar() {
    	cursoService.executeInsert(curso);
    }
    
    public ArrayList<Curso> getCursoList(){
      return cursoList;
    }
    
    public void setCursoList(ArrayList<Curso> cursoList){
      this.cursoList = cursoList;
    }
}
